package client.comm.baoding.adapter

import android.content.Context
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.KTxJl
import client.comm.baoding.databinding.LayoutKtxjlitemBinding
import client.comm.commlib.base.BaseLoadmoreAdapter
import client.comm.commlib.base.BindingViewHoder
import com.bumptech.glide.RequestManager

class KTxjlAdapter : BaseLoadmoreAdapter<KTxJl.Withdraw> {

    val manager: RequestManager

    constructor(context: Context, manager: RequestManager) : super(context) {
        this.manager = manager
    }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {

        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.layout_ktxjlitem,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as LayoutKtxjlitemBinding
        val bean = getItem(position)
        binding.bean = bean
        binding.event = this

//        if (bean.status === 0) {
//            binding.setStatus("审核中")
//            binding.stateTv.setTextColor(context.resources!!.getColor(R.color.fontRed))
//        } else if (bean.status === 1) {
//            binding.setStatus("成功")
//            binding.stateTv.setTextColor(context.resources!!.getColor(R.color.fontGreen))
//        } else if (bean.status === 2) {
//            binding.setStatus("失败")
//            binding.stateTv.setTextColor(context.resources!!.getColor(R.color.fontRed))
//        }
    }


    var cancelKTx: ((bean: KTxJl.Withdraw) -> Unit)? = null
    var reSend: ((bean: KTxJl.Withdraw) -> Unit)? = null

    fun cancelKTx(bean: KTxJl.Withdraw) {
        cancelKTx?.invoke(bean)
    }

    fun reSend(bean: KTxJl.Withdraw) {
        reSend?.invoke(bean)
    }

}